package org.blame.rabbitmqadvancedfeature.listener;

import org.blame.rabbitmqadvancedfeature.constant.Constants;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RetryListener {

    @RabbitListener(queues = Constants.RETRY_QUEUE)
    public void retryListener(Message message){
        long deliveryTag=message.getMessageProperties().getDeliveryTag();
        System.out.printf("接收到的消息:%s,deliveryTag:%s\n",new String(message.getBody()),deliveryTag);
//        int sum=3/0;
//        System.out.println("业务处理完成");


          //如果对异常的信息进行了捕获，那么就不会进行重试
        try {
            int sum=3/0;
            System.out.println("业务处理完成");
        }catch (Exception e){
            System.out.println("业务处理失败");
        }

    }
}
